<?php

class SuggestionsResult
{
	public $aSuggestions; 
}

$data = array("kitchen","bathtub","lawnmower","airplane","zebra","mom","banana","eggplant","stream","pile","wood","dolphin");

// Clear the suggestion list
$rc = new SuggestionsResult();
$rc->aSuggestions = array();

$MAX_SUGGESTIONS = 10;
$query = $_GET['query'];

for($i=0; $i < count($data); $i++)
{
	$pos = stripos($data[$i], $query);
	if(false !== $pos && $pos == 0)
	{
		$rc->aSuggestions [] = $data[$i];
	}
}

for($i=0; $i < count($data); $i++)
{
	$pos = stripos($data[$i], $query);
	if(false !== $pos && $pos > 0)
	{
		$rc->aSuggestions [] = $data[$i];
	}
}

$json = json_encode($rc);

header('X-JSON: (' . $json . ')');
echo $json;
?>